<div class="row" style="margin: 0px">
    <div class="col-sm-12 mt-3" style="border-bottom: 10px solid #f7f8f9;padding-bottom: 1rem;">
        <h4 style="text-align: center;color: #17a2b8;margin-bottom: 0;">申领管理</h4>
    </div>
</div>
<div class="row" style="margin-left: 0px; margin-right: 0px; background-color: white;">
    <div class="col-sm-3 mt-3">
        <div class="input-group input-group-sm">
            <div class="input-group-prepend">
                <div class="input-group-text">账外账内</div>
            </div>
            <select class="form-control" x-ng-model="orderSearchObj.type_account">
                <option value="">请选择</option>
                <option value="OUT">账外</option>
                <option value="IN">账内</option>
            </select>
        </div>
    </div>
    <div class="col-sm-3 mt-3">
        <div class="input-group input-group-sm">
            <div class="input-group-prepend">
                <div class="input-group-text">类型</div>
            </div>
            <select class="form-control" x-ng-model="orderSearchObj.type">
                <option value="">请选择</option>
                <option value="OUT">出库</option>
                <option value="BALANCE">冲销</option>
                <option value="BORROW">借出</option>
            </select>
        </div>
    </div>
    <div class="col-sm-3 mt-3">
        <div class="input-group input-group-sm">
            <div class="input-group-prepend">
                <div class="input-group-text">自建/同步</div>
            </div>
            <select class="form-control" x-ng-model="orderSearchObj.type_from">
                <option value="">请选择</option>
                <option value="IN">自建</option>
                <option value="OUT">同步</option>
            </select>
        </div>
    </div>
    <!-- <div class="col-sm-3 mt-3">
        <div class="input-group input-group-sm">
            <div class="input-group-prepend">
                <div class="input-group-text">审批</div>
            </div>
            <select class="form-control" x-ng-model="orderSearchObj.approval_status">
                <option value="">请选择</option>
                <option value="CHECKING">审批中</option>
                <option value="PASS">审批通过</option>
                <option value="REJECT">审批驳回</option>
            </select>
        </div>
    </div> -->
    <div class="col-sm-3 mt-3">
        <div class="input-group input-group-sm">
            <div class="input-group-prepend">
                <div class="input-group-text">申领人</div>
            </div>
            <select class="form-control" id="claimant_type">
                <option value="SELF">自己</option>
                <option value="OTHER">其他申领人</option>
            </select>
        </div>
    </div>
	<div class="col-sm-3 mt-3">
		<div class="input-group input-group-sm">
			<div class="input-group-prepend">
				<div class="input-group-text">审批方式</div>
			</div>
			<select class="form-control" x-ng-model="orderSearchObj.approval_type">
				<option value="">请选择</option>
				<option value="COMMON">正常</option>
				<option value="URGENT">紧急</option>
			</select>
		</div>
	</div>
    <div class="col-sm-3 mt-3">
        <div class="input-group input-group-sm">
            <div class="input-group-prepend">
                <div class="input-group-text">状态</div>
            </div>
            <select class="form-control" x-ng-model="orderSearchObj.status">
                <option value="">请选择</option>
                <option value="INIT">未完成</option>
                <!--<option value="DOING">处理中</option>-->
                <option value="DONE">已完成</option>
                <option value="UNBACK">待归还</option>
                <option value="BINDED">已绑定</option>
                <option value="BALANCED">已冲销</option>
                <option value="CANCEL">已取消</option>
            </select>
        </div>
    </div>
	<div class="col-sm-4 mt-3">
		<div class="input-group input-group-sm">
			<div class="input-group-prepend">
				<div class="input-group-text">名称</div>
			</div>
			<input class="form-control" x-ng-model="orderSearchObj.show_name" />
		</div>
	</div>
    <div class="col-sm-12 mt-3 mb-3">
        <button x-ng-click="search()" title="搜索" type="button" class="btn btn-sm btn-outline-primary btn-block" style="display: block;width: 100%;margin: 2px;
			border-color: rgba(23,162,184,0.8);background-color: rgba(23,162,184,0.1) ;">
            <i class="fas fa-search" style="color: rgba(23,162,184,1)">&nbsp;搜索</i>
        </button>
    </div>
</div>
<div id="tableDemo" class="row" style="margin-left: 0px; margin-right: 0px; background-color: white;">

</div>

<!-- 弹出选择可以绑定的申领单modal -->
<div class="modal" id="selectBindSldModal" tabindex="-1">
    <div class="modal-dialog modal-dialog-centered modal-lg">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title">选择需要绑定的申领单</h5>
                <button type="button" class="close" ng-click="miClose('selectBindSldModal')">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <div class="modal-body">
                <div id="bindSldTable" class="row"
                     style="margin-left: 0px; margin-right: 0px; background-color: white;">
                </div>
            </div>
        </div>
    </div>
</div>

<!--okokok-->
<div class="modal fade" id="giveBackModel" tabindex="-1">
    <div class="modal-dialog modal-dialog-centered">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title">申领单详情</h5>
                <button type="button" class="close" ng-click="miClose('giveBackModel')">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <div class="modal-body">
                <div class="row" style="margin-left: 0px; margin-right: 0px; background-color: white;">
                    <table x-ng-repeat="viewRecord in giveBackRecordViewList"
                           class="table table-sm table-hover table-bordered">
                        <tbody>
                        <tr>
                            <td style="vertical-align: middle;width:20%">名称</td>
                            <td style="vertical-align: middle;">{{viewRecord.sp_name}}</td>
                        </tr>
                        <tr>
                            <td style="vertical-align: middle;width:20%">CP号</td>
                            <td style="vertical-align: middle;">{{viewRecord.sp_code}}</td>
                        </tr>
                        <tr>
                            <td style="vertical-align: middle;">批次号</td>
                            <td style="vertical-align: middle;">{{viewRecord.batch_code}}</td>
                        </tr>
                        <tr>
                            <td style="vertical-align: middle;width:20%">类型</td>
                            <td style="vertical-align: middle;">{{viewRecord.type | materielTypeFilter}}</td>
                        </tr>
                        <tr>
                            <td style="vertical-align: middle;width:20%">货架/货位</td>
                            <td style="vertical-align: middle;">{{viewRecord.hj_name}} - {{viewRecord.hw_name}}</td>
                        </tr>
                        <tr ng-if="viewRecord.type == 'RFID'">
                            <td style="vertical-align: middle;width:20%">RFID标签</td>
                            <td style="vertical-align: middle;">
                                <input ng-click="openSelectRfidModal(viewRecord)" ng-model="viewRecord.rfid_name"
                                       type="text" class="form-control" readonly>
                            </td>
                        </tr>
                        </tbody>
                    </table>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-sm btn-default" ng-click="submitGiveBack()">
                    <i class="fas fa-check"></i>
                </button>
            </div>
        </div>
    </div>
</div>

<!-- 弹出选择rfid标签的modal -->
<div class="modal fade" id="selectRfidModal" tabindex="-1">
    <div class="modal-dialog modal-dialog-centered modal-lg">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title">选择备件</h5>
                <!-- <button type="button" class="close" ng-click="miClose('selectRfidModal')"> -->
				<button type="button" class="close" x-ng-click="closeSelectRfidModal();">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <div class="modal-body">
				<div class="row" style="margin-left: 0px;margin-right: 0px;background-color: white;">
					<div class="col-sm-5">
						<div class="input-group input-group-sm">
							<div class="input-group-prepend">
								<div class="input-group-text">名称</div>
							</div>
							<input class="form-control" x-ng-model="rfidSearchObj.name" />
						</div>
					</div>
					<div class="col-sm-5 mt-3">
						<div class="input-group input-group-sm">
							<div class="input-group-prepend">
								<div class="input-group-text">编码</div>
							</div>
							<input class="form-control" x-ng-model="rfidSearchObj.code" />
						</div>
					</div>
				    <div class="col-sm-2 mt-3 float-right">
				        <button x-ng-click="rfidPageSearch()" title="搜索" type="button" class="btn btn-sm btn-outline-primary btn-block">
				            <i class="fas fa-search"></i>
				        </button>
				    </div>
				</div>
                <div id="rfidTable" class="row" style="margin-left: 0px; margin-right: 0px; background-color: white;">
                </div>
            </div>
        </div>
    </div>
</div>

<!-- 申领单查看 -- okokok -->
<div class="modal" id="viewStoreModal" tabindex="-1" style="z-index: 1500;">
    <div class="modal-dialog modal-dialog-centered">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title">申领单详情</h5>
                <button type="button" class="close" ng-click="miClose('viewStoreModal')">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <div class="modal-body">
                <div class="row" style="margin-left: 0px; margin-right: 0px; background-color: white;">
                    <table x-ng-repeat="viewRecord in orderRecordViewList"
                           class="table table-sm table-hover table-bordered">
                        <tbody>
                        <tr>
                            <td style="vertical-align: middle;width:20%">名称</td>
                            <td style="vertical-align: middle;">{{viewRecord.name}}</td>
                        </tr>
                        <tr>
                            <td style="vertical-align: middle;width:20%">CP号</td>
                            <td style="vertical-align: middle;">{{viewRecord.sp_code}}</td>
                        </tr>
                        <tr>
                            <td style="vertical-align: middle;">批次号</td>
                            <td style="vertical-align: middle;">{{viewRecord.batch_code}}</td>
                        </tr>
                        <tr>
                            <td style="vertical-align: middle;">类型</td>
                            <td style="vertical-align: middle;">{{viewRecord.type | materielTypeFilter}}</td>
                        </tr>
                        <tr>
                            <td style="vertical-align: middle;">数量</td>
                            <td style="vertical-align: middle;">{{viewRecord.num}}</td>
                        </tr>
                        <tr x-ng-show="viewRecord.type === 'WEIGHT' && viewRecord.order_type === 'BALANCE'">
                            <td style="vertical-align: middle;">货架/货位</td>
                            <td style="vertical-align: middle;word-break: break-all;">{{viewRecord.shelf_show_info}}
                            </td>
                        </tr>
                        <tr x-ng-show="viewRecord.type === 'WEIGHT' && viewRecord.order_type === 'BALANCE'">
                            <td style="vertical-align: middle;">秤/物料盒</td>
                            <td style="vertical-align: middle;word-break: break-all;">{{viewRecord.weight_show_info}}
                            </td>
                        </tr>
                        <tr x-ng-show="viewRecord.type === 'RFID' && viewRecord.order_type === 'BALANCE'">
                            <td style="vertical-align: middle;">已选备件</td>
                            <td style="vertical-align: middle;word-break: break-all;">{{viewRecord.rfid_show_info}}</td>
                        </tr>
                        <tr x-ng-show="viewRecord.type === 'QR' && viewRecord.order_type === 'BALANCE'">
                            <td style="vertical-align: middle;">已选备件</td>
                            <td style="vertical-align: middle;word-break: break-all;">{{viewRecord.qr_show_info}}</td>
                        </tr>
                        </tbody>
                    </table>
                </div>
            </div>
            <div class="modal-header" ng-if="bind_record">
                <h5 class="modal-title">绑定申领单</h5>
            </div>
            <div class="modal-body" ng-if="bind_record">
                <div class="row" style="margin-left: 0px; margin-right: 0px; background-color: white;">
                    <table class="table table-sm table-hover table-bordered">
                        <tbody>
                        <tr>
                            <td style="vertical-align: middle;width:20%">申领人</td>
                            <td style="vertical-align: middle;">{{bind_record.show_name}}</td>
                        </tr>
                        <tr>
                            <td style="vertical-align: middle;width:20%">账内/账外</td>
                            <td style="vertical-align: middle;">{{bind_record.type_account | materielSourceFilter}}</td>
                        </tr>
                        <tr>
                            <td style="vertical-align: middle;width:20%">类型</td>
                            <td style="vertical-align: middle;">{{bind_record.type | orderTypeFilter}}</td>
                        </tr>
                        <tr>
                            <td style="vertical-align: middle;width:20%">自建/同步</td>
                            <td style="vertical-align: middle;">{{bind_record.type_from == 'IN' ? '自建' : '同步'}}</td>
                        </tr>
                        <tr>
                            <td style="vertical-align: middle;width:20%">状态</td>
                            <td style="vertical-align: middle;">{{bind_record.status | orderStatusFilter}}</td>
                        </tr>
                        <tr>
                            <td style="vertical-align: middle;width:20%">创建时间</td>
                            <td style="vertical-align: middle;">{{bind_record.gmt_create}}</td>
                        </tr>
                        <tr>
                            <td style="vertical-align: middle;width:20%">操作时间</td>
                            <td style="vertical-align: middle;">{{bind_record.gmt_modified}}</td>
                        </tr>
                        </tbody>
                    </table>
                </div>
            </div>
			<div class="modal-footer" x-ng-show="orderCancelFlag === 'CLICKABLE' || orderCancelFlag === 'CLICKED' || orderCancelFlag === 'NOCLICK'">
				<button type="button" class="btn btn-sm btn-default" x-ng-click="orderInfoCancel()">
					<!--<i class="fas fa-check"></i>-->
					{{orderCancelFlag == 'CLICKABLE' ? '申领取消' : (orderCancelFlag == 'CLICKED' ? '申领正在取消中' : (orderCancelFlag == 'NOCLICK' ? '暂无法取消申领' : ''))}}
				</button>
			</div>
        </div>
    </div>
</div>
<!-- 同步申领单设置-okokok -->
<div class="modal" id="storeSettingShow" tabindex="-1">
    <div class="modal-dialog modal-dialog-centered">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title">账内申领单设置</h5>
                <button type="button" class="close" ng-click="miClose('storeSettingShow')">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <div class="modal-body">
                <div class="row">
                    <div class="col-sm-12 mt-3 mb-3">
                        <div class="input-group input-group-sm">
                            <div class="input-group-prepend">
                                <div class="input-group-text">申领人</div>
                            </div>
                            <input type="text" class="form-control" x-ng-model="bind.applicant_user"
                                   placeholder="请选择申领人" readonly="readonly" disabled="disabled" />
                            <div class="input-group-append">
                                <button class="btn btn-sm btn-success" type="button" x-ng-click="openSelectUserModal()">
                                    选择
                                </button>
                            </div>
                        </div>
                    </div>
                    <div class="col-sm-12 mt-3 mb-3" ng-if="!tbData.type">
                        <div class="input-group input-group-sm">
                            <div class="input-group-prepend">
                                <div class="input-group-text">类型</div>
                            </div>
                            <select class="form-control" x-ng-model="bind.type">
                                <option value="">请选择</option>
                                <option value="OUT">出库</option>
                                <option value="BORROW">借出</option>
                            </select>
                        </div>
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-sm btn-default" ng-click="submitStoieSetting()">
                    <i class="fas fa-check"></i>
                </button>
            </div>
        </div>
    </div>
</div>
<!-- 弹出选择申领人 --okokok -->
<div class="modal" id="selectUserModal" tabindex="-1">
    <div class="modal-dialog modal-dialog-centered modal-lg">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title">选择申领人</h5>
                <button type="button" class="close" ng-click="miClose('selectUserModal')">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
            <div class="modal-body">
                <!-- 
                <div id="userTable" class="row" style="margin-left: 0px; margin-right: 0px; background-color: white;"></div>
                 -->
                <div id="userTable" class="row" style="background-color: white;"></div>
            </div>
        </div>
    </div>
</div>